import riskClient from "./riskClient";
import { session } from '@core'

export const setSession = (data) => {
  const { token, userCode, userName, unitCode, unitName, roleUnitCode, roleName, roleCode } = data
  session.set('token', token)
  session.set('userName', userName)
  session.set('userCode', userCode)
  session.set('unitCode', unitCode)
  session.set('unitName', unitName)
  session.set('roleCode', roleCode)
  session.set('roleName', roleName)
  session.set('roleUnitCode', roleUnitCode)
}

export const login = async (params) => {
  return await riskClient.postAsync({
    url: 'auth/login',
    params,
    auth:false,
  })
}

export const getCaptcha = async () => {
  return await riskClient.getAsync({
    url: 'auth/getCaptcha',
    auth:false,
    restfull: false
  })
}